from app.core.BaseResponse import success
from app.core.city import city_data
from app.service.menu import nav_name
from app.settings.config import LIMIT


async def metadata():
    """
    获取元数据
    :return:
    """
    home_root_menus = await nav_name(1)  # 首页模块一级菜单
    menu_group_1 = []
    menu_group_2 = []
    menu_group_3 = []
    for menu in home_root_menus:
        menu['isSelected'] = False
        if menu.get('name') in ['关注', '推荐']:
            menu_group_1.append(menu)
        elif menu.get('name') in ['全屋案例', '3D全景']:
            menu_group_2.append(menu)
        else:
            menu_group_3.append(menu)

    data = {
        "homeNavs": [
            {
                "name": "",
                "list": menu_group_1
            },
            {
                "name": "整屋",
                "list": menu_group_2
            },
            {
                "name": "空间",
                "list": menu_group_3
            }
        ],
        "filterNavs": [
            {
                "id": 0,
                "name": "全部",
                "isSelected": False
            },
            {
                "id": 1,
                "name": "全屋案例",
                "isSelected": False
            },
            {
                "id": 2,
                "name": "3D全景",
                "isSelected": False
            },
            {
                "id": 3,
                "name": "图片",
                "isSelected": False
            }
        ],
        "city": city_data,
        "version": 3,
        "userAgreementUrl": "",
        "privacyAgreementUrl": "",
        "homePlaceholder": "请输入组合词语，如：卧室",
        "managePlaceholder": "搜索",
        "designerPlaceholder": "大师名称、作品集",
        "limit": LIMIT,
    }
    return success(data)
